package graphics;

import java.awt.Dimension;
import java.awt.geom.Dimension2D;

import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTextArea;

public class LogWindow extends JFrame
{
	JTextArea status;
	JScrollPane panel;
	
	public LogWindow(String name)
	{
		super(name);
		setResizable(false);

//		panel.setSize(getContentPane().getWidth()-25, getContentPane().getHeight()-25);
		status = new JTextArea();
		status.setAutoscrolls(true);
		status.setBounds(25, 10, getContentPane().getWidth()-25, getContentPane().getWidth()-10);
		panel = new JScrollPane(status);
		add(new JScrollPane(status));		
		setVisible(true);
//		setContentPane(panel);
//		setDefaultCloseOperation(DISPOSE_ON_CLOSE);
	}
	
	private void update(String stuff)
	{
		status.append(stuff);
	}
	
	public void updateUdarilaRaketa(int individua, int raketa, double HP, double dmg)
	{
		update("Individua "+individua+" pogodjena raketom "+raketa+", i od njegovih "+(int)(HP*100)+" HPa mu se skida "+(int)(100*dmg)+" HPa. Novi HP individue "+individua+" je: "+(int)(100*(HP-dmg))+"\n");
	}
	
	public void updateDizheState(int individua, int state)
	{
//		update("Individua "+individua+" dizhe svoj state na "+state+", sa state-a "+(state-1)+"\n");
	}
	
	public void updateSpustaState(int individua, int state)
	{
//		update("Individua "+individua+" spushta svoj state na "+state+", sa state-a "+(state+1)+"\n");
	}
	
	public void updateGricnuoPticu(int individua, int ptica, double HP, double bonus)
	{
		update("Individua "+individua+" gricnuo pticu "+ptica+", i na njegovih "+(int)(100*HP)+" HPa mu se dodaje "+(int)(100*bonus)+" HPa. Novi HP individue "+individua+" je: "+(int)(100*(HP+bonus))+"\n");
	}
	
	public void updatePromashioPticu(int individua, int ptica)
	{
		update("Individua "+individua+" promashio pticu "+ptica+"!\n");
	}
	
	public void updatePromashilaRaketa(int individua, int raketa)
	{
		update("Individua "+individua+" izbegao raketu "+raketa+"!\n");
	}
	
	public void updateNewTurn(int turn)
	{
		update("----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- -----\n"); //50 crtica
		if(turn<10)
			update("----- ----- ----- ----- ----- ----- --- RUNDA "+turn+" ---- ----- ----- ----- ----- ----- -----\n");
		else if(turn<100)
			update("----- ----- ----- ----- ----- ----- --- RUNDA "+turn+" --- ----- ----- ----- ----- ----- -----\n");
		else if(turn<1000)
			update("----- ----- ----- ----- ----- ----- --- RUNDA "+turn+" -- ----- ----- ----- ----- ----- -----\n");
		else 
			update("----- ----- ----- ----- ----- ----- -- RUNDA "+turn+" -- ----- ----- ----- ----- ----- -----\n");
		update("----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- -----\n"); //50 crtica
	}
}
